package com.gfm.story.util;

import com.google.common.hash.HashCode;
import com.google.common.hash.HashFunction;
import com.google.common.hash.Hashing;

import java.nio.charset.Charset;

/**
 * md5加密工具
 * @author Administrator
 *
 */
public class HashUtils {
	//guava Md5函数
	private static final HashFunction FUNCTION = Hashing.md5();
	
	//加盐 防止md5密码被暴力破解
	private static final String SALT = "mooc.com";
	
	public static String encryPassword(String password){
		HashCode hashCode = FUNCTION.hashString(password+SALT, Charset.forName("UTF-8"));//完成md5加密
		return hashCode.toString();
	}
	
}
